package database;

/**
 *
 * @author baena and kadoura
 */
public class Profile {

    private String firstName;
    private String lastName;
    private String login;
    private String password;
    private String email;
    private boolean isAdmin;
    private Status status;

    public Profile(String firstName, String lastName, String password, String email, boolean isAdmin) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.password = password;
        this.email = email;
        this.isAdmin = isAdmin;
        this.login = this.createLogin();
        this.status = Status.DISCONNECTED;
    }

    public Profile(String firstName, String lastName, String password, String email) {
        this(firstName, lastName, password, email, false);
    }

    public Profile(String firstName, String lastName, String password, boolean isAdmin) {
        this(firstName, lastName, password, null, isAdmin);
    }

    public Profile(String firstName, String lastName, String password) {
        this(firstName, lastName, password, null);
    }

    private String createLogin() {
        return (firstName.toLowerCase() + "." + lastName.toLowerCase());
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getLogin() {
        return login;
    }

    public String getPassword() {
        return password;
    }

    public String getEmail() {
        return email;
    }

    public boolean isAdmin() {
        return isAdmin;
    }

    public Status getStatus() {
        return status;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setIsAdmin(boolean isAdmin) {
        this.isAdmin = isAdmin;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public enum Status {

        DISCONNECTED(0),
        CONNECTED(1),
        BUSY(2),
        AWAY(3);

        static Status convertValue(int aInt) {
            switch (aInt) {
                case 0:
                    return DISCONNECTED;
                case 1:
                    return CONNECTED;
                case 2:
                    return BUSY;
                case 3:
                    return AWAY;
                default:
                    return DISCONNECTED;
            }
        }

        private final int value;

        private Status(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }

    };

    @Override
    public String toString() {
        String stg = new String();
        stg = "FirstName : " + this.firstName + "\n";
        stg = stg + "LastName : " + this.lastName + "\n";
        stg = stg + "Login : " + this.login + "\n";
        stg = stg + "Password : " + this.password + "\n";
        if (this.email != null) {
            stg = stg + "Email : " + this.email + "\n";
        }
        stg = stg + "Status : " + this.status + "\n";
        stg = stg + "Admin : " + this.isAdmin + "\n";
        return stg;
    }

}
